<template>
  <div>
    <el-card>
      <div slot="header" class="clearfix text-left">
        <el-col :span="23">
          <span class="title-icon">快速出库</span>
        </el-col>
      </div>
        <el-row style="margin-top: 30px;margin-bottom: 30px">
          <el-col :span="6">
            <el-input
              size="large"
              :rows="5"
              v-model="waybillNos"
              type="textarea"
              placeholder="请输入运单号,多个换行隔开"
            ></el-input>
          </el-col>
          <el-col :span="4" style="margin-left: 10px;">
            <el-button size="mini" type="primary" @click="rapidOutStock()"
              >快速出库</el-button
            >
          </el-col>
        </el-row>
        <el-row>
          <div style="margin-top:10px;color: darkred;font-size: 15px;">
            <span>出库结果:</span>
            <template v-for="(item, value) in result_tips">
              <tr>
                <th >{{ value }} : </th>
                <th >{{ item }}</th>
              </tr>
            </template>
          </div>
        </el-row>
    </el-card>
  </div>
</template>
<script>
import { ajax } from "@/store/yg/common/utils";
import axios from "axios";
import * as constant from "@/store/yg/common/constant";

export default {
  components: {},
  props: [],
  data() {
    return {
      waybillNos:'',
      result_tips: ''
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
  },
  methods: {
    rapidOutStock(){
      ajax("rapidOutStock", { "waybillNos": this.waybillNos }).then(
        res => {
          if (res.code == 200) {
            if (!this.isNotNull(res.data)) {
              this.$message.success("出库成功")
              this.waybillNos = "";
            } else {
              //this.$message.error(res.data);
              this.result_tips = res.data;
            }
          }else{
            this.$message.error("出库失败"+res.message);
          }
        },
        error => {
          console.log(error);
        }
      );
    },
    isNotNull(objStr) {
      if (
        objStr == "" ||
        objStr == null ||
        objStr == "null" ||
        objStr == "undefined" ||
        typeof objStr == "undefined"
      ) {
        return false;
      }
      if (objStr == undefined || typeof objStr == undefined) {
        return false;
      }
      if (typeof objStr == "object" && objStr.length < 1) {
        return false;
      }
      return true;
    },
  }
};
</script>
<style></style>
